"""
    验证层
    wtforms用来验证参数的合法性
"""


from wtforms import Form, StringField, IntegerField
from wtforms.validators import Length, NumberRange, DataRequired


class SearchForm(Form):
    # 至少要有一个字符 Length
    # 要有长度限制 Length
    # 排除空格 DataRequired
    q = StringField(validators=[DataRequired(), Length(min=1, max=30)])
    # 正整数
    # 要有最大值限制
    # 默认值为1
    page = IntegerField(validators=[NumberRange(min=1, max=99)], default=1)
